import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '表类型',
    align: "center",
    dataIndex: 'tableType',
    customRender: ({ text }) => {
      return render.renderDict(text, 'sysTableTyle');
    },
  },
  {
    title: '表名',
    align: "center",
    dataIndex: 'tableName'
  },
  {
    title: '表说明',
    align: "center",
    dataIndex: 'tableTxt'
  },
  {
    title: '版本',
    align: "center",
    dataIndex: 'tableVersion',
    slots: { customRender: 'tableVersion' },
  },
  {
    title: '创建时间',
    align: "center",
    dataIndex: 'createTime'
  },
];

//列表数据
export const tableColumns: BasicColumn[] = [
  {
    title: '表名',
    align: "center",
    dataIndex: 'tableName',
    width: 300,
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    field: 'tableName',
    label: '表名',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: 'tableType',
    label: '表类型',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'sysTableTyle',
    },
    colProps: { span: 6 },
  },
  {
    field: 'tableTxt',
    label: '表说明',
    component: 'Input',
    colProps: { span: 6 },
  },
];
//查询数据
export const tableSearchFormSchema: FormSchema[] = [
  {
    field: 'tableName',
    label: '表名',
    component: 'Input',
    colProps: { span: 8 },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '表名',
    field: 'tableName',
    component: 'Input',
    dynamicDisabled: true,
  },
  {
    label: '表类型',
    field: 'tableType',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'sysTableTyle',
      stringToNumber: true,
    },
    dynamicDisabled: true,
  },
  {
    label: '表版本',
    field: 'tableVersion',
    component: 'InputNumber',
    dynamicDisabled: true,
  },
  {
    label: '表说明',
    field: 'tableTxt',
    component: 'Input',
    dynamicRules: () => {
      return [
        { required: true, message: '请输入表说明!' },
      ];
    },
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];



//表单数据
export const genBaseFormSchema: FormSchema[] = [
  {
    label: '代码生成目录',
    field: 'projectPath',
    component: 'Input',
    dynamicRules: () => {
      return [
        { required: true, },
      ];
    },
  },
  {
    label: '页面风格',
    field: 'jspMode',
    component: 'Select',
    componentProps: {
      valueField: 'code',
      labelField: 'note',
    },
    dynamicRules: () => {
      return [
        { required: true, message: '请选择页面风格!' },
      ];
    },
  },
  {
    label: '功能说明',
    field: 'ftlDescription',
    component: 'Input',
    dynamicRules: () => {
      return [
        { required: true, },
      ];
    },
  },
  {
    label: '表名',
    field: 'tableName',
    component: 'Input',
    dynamicRules: () => {
      return [
        { required: true, message: '请输入表名!' },
      ];
    },
    dynamicDisabled: true,
  },
  {
    label: '实体类名',
    field: 'entityName',
    component: 'Input',
    dynamicRules: () => {
      return [
        { required: true, message: '请输入表名!' },
      ];
    },
  },
  {
    label: '包名(小写)',
    field: 'entityPackage',
    component: 'Input',
    dynamicRules: () => {
      return [
        { required: true, message: '请输入表名!' },
      ];
    },
  },
  {
    label: '页面代码风格',
    field: 'vueStyle',
    component: 'Input',
    dynamicRules: () => {
      return [
        { required: true, },
      ];
    },
    defaultValue: 'vue3',
    dynamicDisabled: true,
    show: false
  },
  {
    label: '代码分层',
    field: 'codeTypes',
    component: 'Input',
    defaultValue: 'controller,service,dao,mapper,entity,vue3',
    dynamicDisabled: true,
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}